<?php
namespace Aplicacao\Form;

use Zend\InputFilter\InputFilter;
use Zend\Validator\StringLength;


/**
 * Filter
 * Filtro e validador do form AtividadeForm
 * @author DiegoWagner
 *
 */
class AtividadeFilter extends InputFilter {
	
	
    /**
     * __construct()
     */
	public function __construct() {
		
		// nome ######################################## NOME (TEXT) ##########################################################
		$this->add(array(
				'name' => 'titulo',
				'required' => true,
				'filters' => array(
						array('name' => 'StripTags'),
						array('name' => 'StringTrim'),
				),
				'validators' => array(
						array(
								'name'    => 'StringLength',
								'break_chain_on_failure' => true,
								'options' => array(
										'encoding' => 'UTF-8',
										'max'      => 45,
										'messages' => array(
												StringLength::TOO_LONG  => 'O campo "Titulo" ultrapassou a quantia de %max% caracteres'
										)
								),
						),
						array(
								'name' => 'NotEmpty',
								'options'=>  array(
										'messages'=> array(
												'isEmpty' => 'O titulo deve ser preenchido!'
										)
								)
						)
				)
		));
		
		
		// descricao ######################################## DESCRICAO (TEXTAREA) ##########################################################
		$this->add(array(
				'name' => 'descricao',
				'required' => true,
				'filters' => array(
						array('name' => 'StripTags'),
						array('name' => 'StringTrim'),
				),
				'validators' => array(
						array(
								'name' => 'NotEmpty',
								'options'=>  array(
										'messages'=> array(
												'isEmpty' => 'A descrição deve ser preenchida!'
										)
								)
						)
				)
		));
	}
	
}